/**
 * 
 */
package cosc617_blackteam;

/**
 * @author Laura
 *Checks if offers are active then applies them
 */
public class CmdGenerateTab implements I_Command {
	private InfoAggregator infoagg;
	private I_Tab tab;
	public CmdGenerateTab(InfoAggregator infoagg, CustomerParty party){
		this.infoagg = infoagg;
		this.tab = new SimpleTab(party);
		
	}
	/* (non-Javadoc)
	 * @see cosc617_blackteam.I_Command#execute()
	 * 
	 * Change the order of the offers in the SpecialOffer enum
	 * if wanting to change the order in which offers are applied
	 */
	@Override
	public Object execute() {
		//for each SpecialOfferEnum
		for (SpecialOffer offer : SpecialOffer.values()){
			//check if offer is enabled
			if(offer.isActive()){
				//if enabled, set the tab equal to the new decorated tab
				tab = offer.applySpecialOffer(tab);
			}
		}
		infoagg.addTab(tab);
		return null;
	}

}
